<template lang="jade">
h-loader-full(url='loader',:setdata='false')
  h-data-lister(data='list')

  m-title(icon="add",name="注册公司列表")
    label 开始时间
    input(type='datetime-local', v-model="start_time")
    label 结束时间
    input(type='datetime-local', v-model="end_time")
    button(@click='filter_time') 过滤
  .box
    //人员信息
    table.list
      ml-header(data='公司名称,注册人名称,联系电话,备注名称,是否反馈,发布时间,反馈时间,备注,操作, 已提交定金')
      tr(v-for='(n,i) in list')
        //td {{n.id}}
        td {{n.com_name}}
        td {{n.person_name}}
        td {{n.mobile}}
        td {{n.option_com_name}}
        td: input(type='checkbox',v-model='n.islink')
        td {{new Date(n.created * 1000).format('yyyy-MM-dd hh:mm:ss') }}
        td(v-if="n.time_check") {{new Date(n.time_check * 1000).format('yyyy-MM-dd hh:mm:ss') }}
        td(v-else)
        td: input(type='text',v-model='n.remark')
        td
          a(href='javascript:void(0)',@click='check(n)') 更新
        td: input(type='checkbox', v-model='n.is_pay' @click="changePay(n.id)")

    .command
      .page
        button(v-show='page>1', @click="pagego('last')") 上一页
        button {{page}}
        button(@click="pagego('next')") 下一页
        a.button(href='javascript:void(0)',@click='download()') 导出
             &nbsp;&nbsp;&nbsp;&nbsp;统计共有{{count_num}}条记录
</template>
<style>
  #title .filter{ padding-top: 0; }
</style>
<script>
import { MessageBox } from 'mint-ui'
export default {
	data () {
		return {
			loader:{
        list:'companyreg/list?page=1'
        },
      list:[],
      page:1,
      count_num:0,
      start_time:"",
      end_time:"",
		}
	},
  mounted () {
    this.getcount()
  },
  watch:{
  },
	methods: {
		loadAfter(data){
      this.list=data.list
		},

    //修改状态
    changePay(id){

      var ok = confirm("确认修改付款状态吗？请谨慎修改");
      if(ok){
        this.$ajax.put('update/companyregpay',{'id':id},(res)=>{
          this.$msg.success(res.message)
          setTimeout("window.location.reload()",1000)
        },(res)=>{
          this.$msg.error(res.message)
        })
      }

    },



    check(obj){
      console.log('obj==',obj)
      this.$ajax.put('update/companyreginfo',{'id':obj.id,'islink':obj.islink,'remark':obj.remark},(res)=>{
        this.$msg.success('更新成功')
        setTimeout('window.location.reload()',1500)
      },(res)=>{
        this.$msg.error('更新失败')
      })
    },
    download(){
        window.location.href = 'http://xiongan.manager.hesq.com.cn/rest/get/excel/companyreg/info'
        //window.location.href = 'http://127.0.0.1:5110/rest/get/excel/companyreg/info'
    },
    // 分页
    pagego (type) {
      var start_time = this.start_time;
      var end_time = this.end_time;
      this.page = type == 'last' ? this.page - 1 : this.page + 1
      this.$ajax.get('companyreg/list?&page=' + this.page + '&start_time='+start_time+"&end_time="+end_time, (res) => {
        this.list = res.data
      }, (res) => {
        this.error(res.message)
      })
    },
    getcount(){
      var start_time = this.start_time;
      var end_time = this.end_time;
      this.$ajax.get('get/companyreg/count?start_time='+start_time+'&end_time='+end_time, (res) => {
        var count_num = 0;
        this.count_num = res.data[0].countnum
      }, (res) => {
        this.error(res.message)
      })
    },
    filter_time(){
      var start_time = this.start_time;
      var end_time = this.end_time;
      this.$ajax.get('companyreg/list?&page=1&start_time='+start_time+"&end_time="+end_time, (res) => {
        this.list = res.data
      }, (res) => {
        this.error(res.message)
      })
      this.getcount();
    }
	}
}
</script>
<style>
  .button{background: #ff5700; padding: 2%; color: #fff; text-decoration-line: none;}
</style>
